package Leetcode.LeetcodeDemo1;

import java.util.PriorityQueue;

public class P2974 {
    public static int[] numberGame(int[] nums) {
        PriorityQueue<Integer> priorityQueue=new PriorityQueue<>();
        int[] arr=new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            priorityQueue.add(nums[i]);
        }
        int j=0;
        while(!priorityQueue.isEmpty()){
            int Alice=priorityQueue.poll();
            int Bob=priorityQueue.poll();
            arr[j++]=Bob;
            arr[j++]=Alice;
        }
        return arr;
    }

}
